<?php
class Table_PageTrans extends CF_Db_Table_Abstract
{
	protected $_name = '##_page_trans';
	
	public function insert($data)
	{
		# get all language id
		$tbLang = new Table_Language();
		$langIds = $tbLang->getCol('id');
		
		$transData = array();
		foreach ($langIds as $langId){
			$data['lang_id'] = $langId;
			$transData[] = $data;
		}
		
		return parent::insert($transData);
	}
	
	public function update($data, $where)
	{
		$data['updated_time'] = time();
		$data['updated_by'] = CF_Auth::getInstance()->getStorage()->getData()->id;
		
		return parent::update($data, $where);
	}
	
	public function detail($pageId, $langId)
	{
		$select = $this->select(
			array('page_id', 'name', 'content'),
			new CF_Db_Expr('page_id= %s AND lang_id=%s', $pageId, $langId)
		);
		return $select->getAt(0);
	}
}